#include <iostream>
#include <vector>

using namespace std;

// 209. 长度最小的子数组
// https://leetcode.cn/problems/minimum-size-subarray-sum/description/

class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int ans = INT32_MAX;
        int left = 0;
        int curSum = 0;
        for (int i = 0; i < nums.size(); i++){
            curSum += nums[i];
            if(curSum >= target){
                ans = min(ans, i - left + 1);
            }
            while(curSum > target){
                curSum -= nums[left++];
            }
            if(curSum >= target){
                ans = min(ans, i - left + 1);
            }
        }
        return ans == INT32_MAX ? 0 : ans;
    }
};

int main()
{
    return 0;
}